package com.zhdl.modules.iiiiiii.controller;

import cn.hutool.core.util.HexUtil;
import com.zhdl.common.ytools.BaseConversionTools;
import com.zhdl.common.ytools.callback.CommonCallback;
import com.zhdl.modules.iiiiiii.jSerialCommTest.SerialPortManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping(path = "/jk", produces = MediaType.APPLICATION_JSON_VALUE)
public class DemoDemoDemoController {

    @GetMapping("/jk1")
    public void init(){
        log.info("打开串口COM5"+ SerialPortManager.getInstance().addPort("COM5",9600,800));
    }

    @GetMapping("/jk2")
    public void demo(long sendCount){
        boolean b = SerialPortManager.getInstance().sendDate("COM5", HexUtil.decodeHex("55 06 01 03 01 66 18 0A 12 0F 2E 03 05 78"), new CommonCallback<String>() {
            @Override
            public void statusCallback(String s) {
                log.info("COM5:收到回调:"+s);
            }
        });
    }

}
